package com.SpringDruid.Config;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class DynamicDataSourceContextHolder {

    public static final ThreadLocal<String> DATASOURCE_HOLDER = new ThreadLocal<>();

    public static void setDataSourceHolder(String dataSource){
        log.info("切换到{}数据源", dataSource);
        DATASOURCE_HOLDER.set(dataSource);
    }

    public static String getDataSourceHolder(){
        return DATASOURCE_HOLDER.get();
    }

    public static void cleanDataSourceHolder(){
        DATASOURCE_HOLDER.remove();
    }

}
